/*
 * @Author: wangming
 * @Date: 2020-09-03 16:33:37
 * @LastEditors: wangming
 * @LastEditTime: 2022-02-07 14:45:52
 * @Description: file content
 */
import myMixin from '@/pageComponents/myMixin';
import vmMixin from "@/pageComponents/vmMixin";
export default {
  mixins: [myMixin, vmMixin],
  created() {
    if (this.datas === undefined) {
      this.datas = this.config.__config.defaultValue;
    }
  },
  methods: {
    def() {
      this.datas = this.value;
    }
  },
  data() {
    return {
      datas: ''
    };
  },
  watch: {
    value: {
      handler: 'def',
      immediate: true
    },
    datas(v) {
      this.$emit('input', v);
    }
  },
  render(h) {
    const { openValue, closeValue } = this.config.__config;
    return h('el-switch', {
      on: {
        change: (v) => {
          this.runEventName('change', { values: v });
        }
      },
      style: { height: '32px', 'padding-bottom': '11px' },
      model: {
        value: this.datas,
        callback: (v) => {
          this.datas = v;
        },
        expression: 'datas'
      },
      attrs: {
        disabled: this.disabled || this.viewInfo,
        activeValue: openValue,
        inactiveValue: closeValue
      }
    });
  }
};
